-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor interop to use CsWin32/LibraryImport #49
Conversation
Signed-off-by: Ryan Luu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.
Files not reviewed (2)
- FluentAutoClicker/FluentAutoClicker.csproj: Language not supported
- FluentAutoClicker/NativeMethods.txt: Language not supported
Comments suppressed due to low confidence (1)
FluentAutoClicker/MainPage.xaml.cs:42
- The 'wndProc' field is initialized to 'null!' and then assigned later. This could lead to a null reference issue if 'HotKeyProc' is called before 'MainPage_Loaded'. Initialize 'wndProc' properly.
private WNDPROC wndProc = null!;
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.
Files not reviewed (3)
- FluentAutoClicker/FluentAutoClicker.csproj: Language not supported
- FluentAutoClicker/MainPage.xaml: Language not supported
- FluentAutoClicker/NativeMethods.txt: Language not supported
Comments suppressed due to low confidence (1)
FluentAutoClicker/Program.cs:74
- The lpName parameter is nullable. Ensure that the nullability is handled correctly, either by adding a null check or handling the nullability explicitly.
string? lpName);
Description
Modernizes interop to replace
DllImport
withLibraryImport
orPInvoke
with CsWin32 when possible. The goal of this PR is to improve project readability by reducing complexity. This paves the path for being able to add bindable hotkeys in the future.They are some trade-offs in this PR as it adds CsWin32 as a dependency and CsWin32 still uses DllImport instead of LibraryImport which may pose some AOT issues.
Related Issues
Changes Made
Code Modernization:
FluentAutoClicker/App.xaml.cs
: Replaced the staticWindow
property withMainWindow
and updated theOnLaunched
method to activateMainWindow
directly. [1] [2]FluentAutoClicker/Helpers/AutoClicker.cs
: Converted P/Invoke declarations to use source-generated interop withLibraryImport
.FluentAutoClicker/Program.cs
: Updated P/Invoke declarations to use source-generated interop withLibraryImport
.Dependency Updates:
FluentAutoClicker/FluentAutoClicker.csproj
: Enabled unsafe blocks and added a package reference forMicrosoft.Windows.CsWin32
. [1] [2]Code Cleanup:
FluentAutoClicker/Helpers/WindowMessageHook.cs
: Removed theWindowMessageHook
class and related interop code as it is no longer needed.Hotkey Handling:
FluentAutoClicker/MainPage.xaml.cs
: Refactored hotkey handling to use Windows API directly and removed the old interop code. [1] [2]Native Methods:
FluentAutoClicker/NativeMethods.txt
: Added new native methods used in the updated hotkey handling.Checklist
LibraryImport
SendInput
inAutoClicker.cs
to reduce lines of codeAdditional Notes